package com.zbf.tspring.web;

import com.zbf.tspring.service.TestService2;
import com.zbf.tspring.service.TestService3;
import com.zbf.tspring.service.TestService4;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;

/**
 * @author: LCG
 * 作者: LCG
 * 日期: 2021/3/22  9:43
 * 描述:
 */
@RestController
public class TestController2 {

    @Autowired
    private TestService3 testService3;

    @Autowired
    private TestService2 testService2;

    @Autowired
    private TestService4 testService4;

    @RequestMapping("test31")
    public  void test31() throws ExecutionException, InterruptedException {
        testService3.test31();
    }


    @RequestMapping("test32")
    public void test32(){
        Map<String,Object> map=new HashMap<>();
        map.put("id",3);
        map.put("quantity",300);
        testService2.test02(map);
    }


    @RequestMapping("test0041")
    public void test0041(){
        testService4.test41();
    }



    public static void main(String[] args) {

        Thread t1=new Thread(new Runnable() {
            @SneakyThrows
            @Override
            public void run() {

                for(int i=1;i<=10;i++){

                    if(i%2!=0){
                        Thread.sleep(i*100);
                        System.out.println("t1--"+i);
                    }
                }

            }
        });

        Thread t2=new Thread(new Runnable() {
            @SneakyThrows
            @Override
            public void run() {
                for(int i=1;i<=10;i++){

                    if(i%2==0){
                        Thread.sleep(i*100);
                        System.out.println("t2--"+i);
                    }

                }
            }
        });

        t1.start();
        t2.start();


    }


}
